load("@npm//@bazel/typescript:index.bzl", "ts_devserver")
load("//:packages.bzl", "getAngularUmdTargets")
load("//tools:defaults.bzl", "ng_module", "sass_binary")

package(default_visibility = ["//visibility:public"])

exports_files([
    "protractor.conf.js",
    "start-devserver.js",
    "devserver-configure.js",
])

ng_module(
    name = "e2e-app",
    testonly = True,
    srcs = glob(
        ["**/*.ts"],
        exclude = ["test-util/**"],
    ),
    assets = glob(
        [
            "**/*.html",
            "**/*.css",
        ],
        exclude = ["index.html"],
    ),
    deps = [
        "//src/cdk-experimental/dialog",
        "//src/cdk-experimental/scrolling",
        "//src/cdk/drag-drop",
        "//src/cdk/overlay",
        "//src/cdk/scrolling",
        "//src/cdk/testing/tests:test_components",
        "//src/components-examples/material-experimental/mdc-card",
        "//src/components-examples/private",
        "//src/material-experimental/mdc-button",
        "//src/material-experimental/mdc-card",
        "//src/material-experimental/mdc-checkbox",
        "//src/material-experimental/mdc-chips",
        "//src/material-experimental/mdc-dialog",
        "//src/material-experimental/mdc-input",
        "//src/material-experimental/mdc-menu",
        "//src/material-experimental/mdc-progress-bar",
        "//src/material-experimental/mdc-progress-spinner",
        "//src/material-experimental/mdc-radio",
        "//src/material-experimental/mdc-slide-toggle",
        "//src/material-experimental/mdc-slider",
        "//src/material-experimental/mdc-table",
        "//src/material-experimental/mdc-tabs",
        "//src/material/button",
        "//src/material/checkbox",
        "//src/material/core",
        "//src/material/dialog",
        "//src/material/form-field",
        "//src/material/grid-list",
        "//src/material/icon",
        "//src/material/input",
        "//src/material/list",
        "//src/material/menu",
        "//src/material/progress-bar",
        "//src/material/progress-spinner",
        "//src/material/radio",
        "//src/material/sidenav",
        "//src/material/slide-toggle",
        "//src/material/tabs",
        "@npm//@angular/animations",
        "@npm//@angular/core",
        "@npm//@angular/elements",
        "@npm//@angular/forms",
        "@npm//@angular/platform-browser",
        "@npm//@angular/router",
    ],
)

sass_binary(
    name = "theme",
    src = "theme.scss",
    include_paths = [
        "external/npm/node_modules",
    ],
    deps = [
        "//src/material-experimental/mdc-theming:all_themes",
        "//src/material-experimental/mdc-typography:all_typography",
        "//src/material/core:theming_scss_lib",
    ],
)

ts_devserver(
    name = "devserver",
    testonly = True,
    additional_root_paths = [
        "npm/node_modules",
    ],
    # Name of the AMD module that should be required on page load.
    entry_module = "angular_material/src/e2e-app/main",
    port = 4200,
    # Scripts which will be included in the serving_path bundle after
    # RequireJS has been loaded.
    scripts = [
        ":devserver-configure.js",
        "//tools/rxjs:rxjs_umd_modules",
        "@npm//:node_modules/tslib/tslib.js",
    ] + getAngularUmdTargets(),
    # Serving path of the bundle that serves all files specified in "deps" and "scripts".
    serving_path = "/bundle.js",
    # Files which should be provided by Bazel when running the devserver. These are not
    # automatically served, but can be loaded manually through HTTP requests.
    static_files = [
        "@npm//zone.js",
        "@npm//core-js",
        "@npm//kagekiri",
        "@npm//material-components-web",
        "@npm//moment",
        "@npm//@webcomponents/custom-elements",
        "//src/material/prebuilt-themes:indigo-pink",
        ":index.html",
        ":theme",
    ],
    tags = ["manual"],
    deps = [":e2e-app"],
)
